Imports System.Text
Public Class Utils

    ''' <summary>
    ''' Verifies if the character is an alphabet
    ''' </summary>
    ''' <param name="ch">Any character of type Char</param>
    ''' <returns>True if alphabet, false if not.</returns>
    ''' <remarks></remarks>
    Public Shared Function IsAlphabet(ByRef ch As Char) As Boolean
        Dim iAsc As Integer = Asc(ch)
        If (iAsc >= 65 AndAlso iAsc <= 90) OrElse (iAsc >= 97 AndAlso iAsc <= 122) Then
            Return True
        Else
            Return False
        End If
    End Function

    ''' <summary>
    ''' Gets the equivalent character from Tempelate string.
    ''' </summary>
    ''' <param name="Ch">The character whose equivalent is to be retreived.</param>
    ''' <param name="Tempelate">The string containing the Tempelate from which the equivalent character is retreived.</param>
    ''' <returns>Equivalent character from Tempelate string.</returns>
    ''' <remarks></remarks>
    Public Shared Function GetNewChar(ByVal Ch As Char, ByVal Tempelate As String) As Char
        Dim iAsc As Integer = Asc(Ch)

        'If Uppercase, change it to lower
        If iAsc >= 65 AndAlso iAsc <= 90 Then
            iAsc += 32
        End If

        Dim newchar As Char = Mid(Tempelate, iAsc - 96, 1).ToCharArray(0, 1)(0)
        Return newchar
    End Function

    ''' <summary>
    ''' Writes the given text to Clipboard.
    ''' </summary>
    ''' <param name="Data">The text data that needs to be copied to clipboard.</param>
    ''' <remarks></remarks>
    Public Shared Sub WriteToClipBoard(ByVal Data As String)
        If String.IsNullOrEmpty(Data) Then Exit Sub
        Clipboard.SetText(Data, TextDataFormat.UnicodeText)
    End Sub
End Class
